package com.hundsun.cprs.yyt.service.order.dto;

import com.hundsun.cprs.yyt.common.enums.EnumAreaCode;
import com.hundsun.cprs.yyt.service.goods.domain.GoodsSpecs;
import com.hundsun.cprs.yyt.service.goods.dto.GoodsInfo;
import com.hundsun.cprs.yyt.service.order.domain.OrderItem;

public class GoodsItem {

    private GoodsInfo goods;
    private GoodsSpecs sku;
    private Integer quantity;

    public GoodsSpecs getSku() {
        return sku;
    }

    public void setSku(GoodsSpecs sku) {
        this.sku = sku;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public GoodsInfo getGoods() {
        return goods;
    }

    public void setGoods(GoodsInfo goods) {
        this.goods = goods;
    }
    
    public boolean isFromRetailArea(){
        return EnumAreaCode.RETAIL_AREA.getCode().equals(getSku().getAreaCode());
    }
    
    public boolean isFromWholesaleArea(){
        return EnumAreaCode.WHOLESALE_AREA.getCode().equals(getSku().getAreaCode());
    }
    
    public Double getIntegralRewardRate(){
        //零售区订单设置赠送积分比例
        return isFromRetailArea()?goods.getIntegralRewardRate():0d;
    }
    
    public Double getQuotaRewardRate(){
        //零售区订单设置赠送配额比例
        return isFromRetailArea()?goods.getQuotaRewardRate():0d;
    }
    
    public Long getQuotaAmount(){
        //批发区订单需要支付的配额
        return isFromWholesaleArea()?new Long(sku.getQuotaAmount()):0l;
    }

}
